<?php
declare(strict_types=1);

namespace app\admin\business;
use app\common\model\Attachment as AttachmentModel;

class Attachment extends AdminBase
{
    private $_attachmentObj = null;

    public function __construct(string $websiteCode)
    {
        $this->_websiteCode = $websiteCode;
        $this->_attachmentObj       = new AttachmentModel([], $websiteCode);
    }

    public function addAttachment(array $data): array
    {
        try {
            return [self::_RESULT => $this->_attachmentObj->addAttachment($data), self::_MESSAGE => self::_ADD_SUCCESS_MESSAGE];
        } catch (\Exception $e) {
            logErr('添加广告失败', sprintf('websiteCode:%s,method:%s,err:%s', $this->_websiteCode, __METHOD__, $e->getMessage()));
        }

        return [self::_RESULT => false, self::_MESSAGE => self::_SYSTEM_ERROR_MESSAGE];
    }

}